#include "imgarea.h"
#include<QImage>
#include<qdebug.h>
#include<opencv2/opencv.hpp>
#include<opencv2/imgproc/types_c.h>

ImgArea::ImgArea(){
    setScaledContents(true);
}

void ImgArea::setImg(cv::Mat matImg){
    QImage img;
    if(matImg.channels() == 3){
        img=QImage((const unsigned char*)(matImg.data),matImg.cols,matImg.rows,matImg.cols*matImg.channels(),QImage::Format_RGB888);
    }
    else{
        img=QImage((const unsigned char*)(matImg.data),matImg.cols,matImg.rows,matImg.cols*matImg.channels(),QImage::Format_Indexed8);
    }
    setPixmap(QPixmap::fromImage(img));
    show();
}
